#ifndef CPURANKITEM_H
#define CPURANKITEM_H

#include <QWidget>

namespace Ui {
class CpuRankItem;
}

class CpuRankItem : public QWidget
{
    Q_OBJECT
    Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged FINAL)
    Q_PROPERTY(QString mingCheng READ mingCheng WRITE setMingCheng NOTIFY mingChengChanged FINAL)
public:
    explicit CpuRankItem(QWidget *parent = nullptr);
    ~CpuRankItem();

    static CpuRankItem* fromMap(const QVariantMap &map, CpuRankItem *item = nullptr);

    QString id() const;
    void setId(const QString &newId);

    QString mingCheng() const;
    void setMingCheng(const QString &newMingCheng);

signals:
    void idChanged();
    void mingChengChanged();
    void switchIdChagned(const QString &id, bool switched);

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

private:
    Ui::CpuRankItem *ui;

    QString m_id;
    QString m_mingCheng;

    QPoint m_onePos;

private:
    void setSwtiched(bool value);
    friend class CpuRankItemDelegate;
};

#endif // CPURANKITEM_H
